package domain.PDU.Tag;

import java.util.HashMap;

/**
 * @Author: ylc
 * @Description:数据标签与值
 */
public class TagType {
    /**
     * UNIVERSAL1
     */
    public static final String BOOLEAN = "BOOLEAN";
    /**
     * UNIVERSAL2
     */
    public static final String INTEGER = "INTEGER";
    /**
     * UNIVERSAL3
     */
    public static final String BIT_STRING = "BIT STRING";
    /**
     * UNIVERSAL4
     */
    public static final String OCTET_STRING = "OCTET STRING";
    /**
     * UNIVERSAL5
     */
    public static final String NULL = "NULL";
    /**
     * UNIVERSAL6
     */
    public static final String OBJECT_IDENTIFIER = "OBJECT IDENTIFIER";
    /**
     * UNIVERSAL16
     */
    public static final String SEQUENCE = "SEQUENCE";

    /**
     * 存储类型与标签值的映射
     */
    private static final HashMap<String,Byte> tagCoding = new HashMap<>();
    /**
     * 存储标签值与类型的映射
     */
    private static final HashMap<Byte,String> codingTag = new HashMap<>();

    public TagType() {
    }

    static{
        // 存入编码后对应的十六进制数
        tagCoding.put(TagType.BOOLEAN,(byte)0x1);
        tagCoding.put(TagType.INTEGER,(byte)0x2);
        tagCoding.put(TagType.BIT_STRING,(byte)0x3);
        tagCoding.put(TagType.OCTET_STRING,(byte)0x4);
        tagCoding.put(TagType.NULL,(byte)0x5);
        tagCoding.put(TagType.OBJECT_IDENTIFIER,(byte)0x6);
        tagCoding.put(TagType.SEQUENCE,(byte)0x30);
        // 存入十六进制数对应的标签
        codingTag.put((byte)0x1,TagType.BOOLEAN);
        codingTag.put((byte)0x2,TagType.INTEGER);
        codingTag.put((byte)0x3,TagType.BIT_STRING);
        codingTag.put((byte)0x4,TagType.OCTET_STRING);
        codingTag.put((byte)0x5,TagType.NULL);
        codingTag.put((byte)0x6,TagType.OBJECT_IDENTIFIER);
        codingTag.put((byte)0x30,TagType.SEQUENCE);
    }
    public static HashMap<String, Byte> getTagCoding() {
        return tagCoding;
    }
    public static HashMap<Byte, String> getCodingTag() {
        return codingTag;
    }
}
